{% extends 'base.html' %}
{% block content%}

<form method="post" enctype="multipart/form-data">
    <div class="form-group">
        <label for="title">标题</label>
        <input type="text" name="title" placeholder="标题" class="form-control" value="{{ request.form['title'] or post['title'] }}">
    </div>

    <div class="form-group">
        <label for="content">内容</label>
        <textarea name="content" placeholder="Post content" class="form-control">{{ request.form.get('content', post['content']) }}</textarea>
    </div>

    {% if post.image_filename %}
    <div class="form-group">
        <label for="currentImage">对应图片：</label><br>
        <img src="{{ url_for('static', filename='uploads/' + post.image_filename) }}" alt="Current Image" style="max-width: 600px;">
    </div>
    {% endif %}

    {% if current_user.is_authenticated %}
    <div class="form-group">
        <label for="imageUpload">选择修改后的图片：</label>
        <input type="file" id="imageUpload" name="image" accept="image/*">
    </div>
    {% endif %}

    {% if current_user.is_authenticated %}
    <div class="form-group">
        <button type="submit" class="btn btn-primary">提交</button>
    </div>
    {% endif %}
</form>
<hr>
{% endblock %}